package com.bx.market;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import junit.framework.Assert;
import junit.framework.TestCase;
import com.bx.market.Event;
import com.bx.market.EventDAO;

/**
 * Created by IntelliJ IDEA.
 * com.bx.user.User: nutej
 * Date: Jan 16, 2008
 * Time: 10:15:46 AM
 * To change this template use File | Settings | File Templates.
 */
public class EventDAOTest extends TestCase {
    private ApplicationContext ctx = null;
    private Event record = null;
    private EventDAO dao = null;

    public EventDAOTest() {
        // Should put in a parent class that extends TestCase
        String[] paths = {"spring-config.xml"};
        ctx = new ClassPathXmlApplicationContext(paths);
    }

    protected void setUp() throws Exception {
        super.setUp();
        dao = (EventDAO) ctx.getBean("eventDAO");
    }

    protected void tearDown() throws Exception {
        super.tearDown();
        dao = null;
    }

    public void testSaveRecord() throws Exception {
        record = new Event();
        record.setName("Slovan Zapad - PivoPlayaz");

        dao.saveRecord(record);
        Assert.assertNotNull("primary key assigned", record.getId());
    }

}